package main

import (
	"fmt"
	"topobuild/base"
	"topobuild/bgpv1"
	"topobuild/isisv1"
	"topobuild/simu"
	"topobuild/utils"
)

func main() {
	filename := "topo.yaml"
	conf := base.NewConfigFromFile(filename)
	if conf == nil {
		return
	}
	kp := simu.NewSimuKeeper()
	bgp := bgpv1.NewBgpV1()
	isis := isisv1.NewIsisV1()

	outfile := "out.xlsx"
	utils.RemoveFile(outfile)
	kp.GenTableDevice(conf, outfile)
	kp.GenTableIntface(conf, outfile)
	kp.GenTableLink(conf, outfile)

	outfile = "bgp.xlsx"
	utils.RemoveFile(outfile)
	bgp.GenTableNode(kp, conf, outfile)
	bgp.GenTableNeighbor(kp, conf, outfile)
	bgp.GenTableUnicast(kp, conf, outfile)
	bgp.GenTableRoute(kp, conf, outfile)

	outfile = "isis.xlsx"
	utils.RemoveFile(outfile)
	isis.GenTableNode(kp, conf, outfile)
	isis.GenTableInterface(kp, conf, outfile)

	var devname string
	for {
		// 输入设备名称到devname
		fmt.Printf("Dev> ")
		if _, err := fmt.Scanln(&devname); err != nil {
			fmt.Println(err)
			break
		}
		// output devinfo
		kp.ShowDevInfo(devname, conf)
		fmt.Printf("=========================\n")
	}
}
